<?php

namespace app\index\validate\lawyer;

use ShidianUtil\Thinkphp\Validate\BaseValidate;

/**
 * Class CityTree
 * @package app\lawyer\validate
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037623
 */
class CityTree extends BaseValidate
{

    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id'	=> 'isId',
		'name'	=> 'scalar|max:50',
		'nid'	=> 'scalar|max:50',
		'status'	=> 'integer|max:2',
		'pid'	=> 'integer|max:11',
		'province'	=> 'integer|max:11',
		'city'	=> 'integer|max:11',
		'domain'	=> 'scalar|max:100',
		'order'	=> 'integer|max:11',
		'areas_num'	=> 'integer|egt:0|max:10',
        'page'      => 'integer|egt:0|max:11',
        'page_size' => 'integer|egt:0|max:11',
    ];

    protected $field = [
        'id'	=> 'id',
		'name'	=> 'name',
		'nid'	=> 'nid',
		'status'	=> 'status',
		'pid'	=> 'pid',
		'province'	=> 'province',
		'city'	=> 'city',
		'domain'	=> 'domain',
		'order'	=> 'order',
		'areas_num'	=> 'areas_num',
        'page'      => '分页页数',
        'page_size' => '分页大小',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'id.require'	=> '缺少:attribute',
		'id.isId'	=> '请设置正确的:attribute',
		'name.require'	=> '请输入:attribute',
		'name.scalar' => ':attribute应该是字符串',
		'name.max'	=> ':attribute长度不能超过:rule位',
		'nid.require'	=> '请输入:attribute',
		'nid.scalar' => ':attribute应该是字符串',
		'nid.max'	=> ':attribute长度不能超过:rule位',
		'status.require'	=> '请输入:attribute',
		'status.integer' => ':attribute应该是整数',
		'status.max'	=> ':attribute长度不能超过:rule位',
		'pid.require'	=> '请输入:attribute',
		'pid.integer' => ':attribute应该是整数',
		'pid.max'	=> ':attribute长度不能超过:rule位',
		'province.require'	=> '请输入:attribute',
		'province.integer' => ':attribute应该是整数',
		'province.max'	=> ':attribute长度不能超过:rule位',
		'city.require'	=> '请输入:attribute',
		'city.integer' => ':attribute应该是整数',
		'city.max'	=> ':attribute长度不能超过:rule位',
		'domain.require'	=> '请输入:attribute',
		'domain.scalar' => ':attribute应该是字符串',
		'domain.max'	=> ':attribute长度不能超过:rule位',
		'order.require'	=> '请输入:attribute',
		'order.integer' => ':attribute应该是整数',
		'order.max'	=> ':attribute长度不能超过:rule位',
		'areas_num.require'	=> '请输入:attribute',
		'areas_num.integer' => ':attribute应该是整数',
		'areas_num.egt'	=> ':attribute应该大于等于:rule',
		'areas_num.max'	=> ':attribute长度不能超过:rule位',
        'page.require'      => '请输入:attribute',
        'page.integer'      => ':attribute应该是整数',
        'page.egt'          => ':attribute应该大于等于:rule',
        'page.max'          => ':attribute长度不能超过:rule位',
        'page_size.require' => '请输入:attribute',
        'page_size.integer' => ':attribute应该是整数',
        'page_size.egt'     => ':attribute应该大于等于:rule',
        'page_size.max'     => ':attribute长度不能超过:rule位',
    ];

    protected $scene = [
        'delete' => ['id' => 'require'],
        'index'  => ['page', 'page_size'],
        'read'   => ['id' => 'require'],
        'save'   => ['name', 'nid', 'status', 'pid', 'province', 'city', 'domain', 'order', 'areas_num'],
    ];

}
